Move angle normalization code from various places to tools
Also rename svx angle normalization functions in include/svx/svdtrans.hxx, that
deal with 100ths of degree, to avoid confusion: NormAngle180 -> NormAngle18000;
NormAngle360 -> NormAngle36000.
Some places were fixed that previously returned inclusive ranges (i.e., both 0
and 360), see changes in these files:
chart2/source/view/main/PlottingPositionHelper.cxx
chart2/source/view/main/PolarLabelPositionHelper.cxx
chart2/source/view/main/ShapeFactory.cxx
filter/source/graphicfilter/idxf/dxf2mtf.cxx
sw/source/core/graphic/grfatr.cxx
(the latter now matches the comment in the function).
Change-Id: I9f274bbb4168360d60dceff02aeba6332c519a59
Reviewed-on: https://gerrit.libreoffice.org/58556
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
diff --git a/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx b/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx
index ae8449d..acc07bc 100644
--- a/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx
+++ b/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx
@@ -27,6 +27,7 @@
#include <editeng/unoprnms.hxx>
#include <com/sun/star/drawing/ProjectionMode.hpp>
#include <tools/diagnose_ex.h>
#include <tools/helpers.hxx>
namespace chart
{
@@ -36,15 +37,6 @@
namespace
{
void lcl_shiftAngleToValidRange( sal_Int64& rnAngleDegree )
{
//valid range: ]-180,180]
while( rnAngleDegree<=-180 )
rnAngleDegree+=360;
while( rnAngleDegree>180 )
rnAngleDegree-=360;
}
void lcl_SetMetricFieldLimits( MetricField& rField, sal_Int64 nLimit )
{
rField.SetMin(-1*nLimit);
@@ -87,13 +79,12 @@
lcl_SetMetricFieldLimits( *m_pMFZRotation, 90 );
m_nXRotation = ::basegfx::fround(fXAngle*pow(10.0,m_pMFXRotation->GetDecimalDigits()));
m_nYRotation = ::basegfx::fround(-1.0*fYAngle*pow(10.0,m_pMFYRotation->GetDecimalDigits()));
m_nZRotation = ::basegfx::fround(-1.0*fZAngle*pow(10.0,m_pMFZRotation->GetDecimalDigits()));
lcl_shiftAngleToValidRange( m_nXRotation );
lcl_shiftAngleToValidRange( m_nYRotation );
lcl_shiftAngleToValidRange( m_nZRotation );
m_nXRotation = NormAngle180(
::basegfx::fround(fXAngle * pow(10.0, m_pMFXRotation->GetDecimalDigits())));
m_nYRotation = NormAngle180(
::basegfx::fround(-1.0 * fYAngle * pow(10.0, m_pMFYRotation->GetDecimalDigits())));
m_nZRotation = NormAngle180(
::basegfx::fround(-1.0 * fZAngle * pow(10.0, m_pMFZRotation->GetDecimalDigits())));
m_pMFXRotation->SetValue(m_nXRotation);
m_pMFYRotation->SetValue(m_nYRotation);
diff --git a/chart2/source/tools/ThreeDHelper.cxx b/chart2/source/tools/ThreeDHelper.cxx
index 25da0b3..3967ce4 100644
--- a/chart2/source/tools/ThreeDHelper.cxx
+++ b/chart2/source/tools/ThreeDHelper.cxx
@@ -30,6 +30,7 @@
#include <com/sun/star/drawing/LineStyle.hpp>
#include <com/sun/star/drawing/ShadeMode.hpp>
#include <tools/diagnose_ex.h>
#include <tools/helpers.hxx>
#include <sal/log.hxx>
namespace chart
@@ -369,24 +370,6 @@
return fAngleRad;
}
void lcl_shiftAngleToIntervalMinus180To180( sal_Int32& rnAngleDegree )
{
//valid range: ]-180,180]
while( rnAngleDegree<=-180 )
rnAngleDegree+=360;
while( rnAngleDegree>180 )
rnAngleDegree-=360;
}
void lcl_shiftAngleToIntervalZeroTo360( sal_Int32& rnAngleDegree )
{
//valid range: [0,360[
while( rnAngleDegree<0 )
rnAngleDegree+=360;
while( rnAngleDegree>=360 )
rnAngleDegree-=360;
}
void lcl_ensureIntervalMinus1To1( double& rSinOrCos )
{
if (rSinOrCos < -1.0)
@@ -414,8 +397,8 @@
//https://bz.apache.org/ooo/show_bug.cgi?id=72994
//https://bz.apache.org/ooo/attachment.cgi?id=50608
lcl_shiftAngleToIntervalZeroTo360( nElevationDeg );
lcl_shiftAngleToIntervalZeroTo360( nRotationDeg );
nElevationDeg = NormAngle360(nElevationDeg);
nRotationDeg = NormAngle360(nRotationDeg);
double& x = rfXAngleRad;
double& y = rfYAngleRad;
@@ -1053,8 +1036,8 @@
// nZRotation = basegfx::fround(-1.0 * basegfx::rad2deg(fZAngle));
}
lcl_shiftAngleToIntervalMinus180To180( rnHorizontalAngleDegree );
lcl_shiftAngleToIntervalMinus180To180( rnVerticalAngleDegree );
rnHorizontalAngleDegree = NormAngle180(rnHorizontalAngleDegree);
rnVerticalAngleDegree = NormAngle180(rnVerticalAngleDegree);
}
void ThreeDHelper::setRotationToDiagram( const uno::Reference< beans::XPropertySet >& xSceneProperties
diff --git a/chart2/source/view/charttypes/PieChart.cxx b/chart2/source/view/charttypes/PieChart.cxx
index de48a1d..19f978e 100644
--- a/chart2/source/view/charttypes/PieChart.cxx
+++ b/chart2/source/view/charttypes/PieChart.cxx
@@ -33,6 +33,7 @@
#include <com/sun/star/container/XChild.hpp>
#include <rtl/math.hxx>
#include <sal/log.hxx>
#include <tools/helpers.hxx>
#include <memory>
@@ -759,16 +760,6 @@
return (fAngleDeg / 180) * M_PI;
}
inline
double lcl_getDegAngleInStandardRange(double fAngle)
{
while( fAngle < 0.0 )
fAngle += 360.0;
while( fAngle >= 360.0 )
fAngle -= 360.0;
return fAngle;
}
}//end anonymous namespace
PieChart::PieLabelInfo::PieLabelInfo()
@@ -1277,10 +1268,10 @@
"** PieChart::performLabelBestFitInnerPlacement invoked **" );
// get pie slice properties
double fStartAngleDeg = lcl_getDegAngleInStandardRange(rShapeParam.mfUnitCircleStartAngleDegree);
double fStartAngleDeg = NormAngle360(rShapeParam.mfUnitCircleStartAngleDegree);
double fWidthAngleDeg = rShapeParam.mfUnitCircleWidthAngleDegree;
double fHalfWidthAngleDeg = fWidthAngleDeg / 2.0;
double fBisectingRayAngleDeg = lcl_getDegAngleInStandardRange(fStartAngleDeg + fHalfWidthAngleDeg);
double fBisectingRayAngleDeg = NormAngle360(fStartAngleDeg + fHalfWidthAngleDeg);
// get the middle point of the arc representing the pie slice border
double fLogicZ = rShapeParam.mfLogicZ + 1.0;
@@ -1334,7 +1325,7 @@
double fLabelHeight = aBb.getHeight();
// -45 <= fAlphaDeg < 315
double fAlphaDeg = lcl_getDegAngleInStandardRange(fBisectingRayAngleDeg + 45) - 45;
double fAlphaDeg = NormAngle360(fBisectingRayAngleDeg + 45) - 45;
double fAlphaRad = lcl_degToRad(fAlphaDeg);
// compute nearest edge index
@@ -1507,7 +1498,7 @@
// check the angle between CP and CM
double fAngleRad = aPositionalVector.angle(aVertexM);
double fAngleDeg = lcl_getDegAngleInStandardRange( lcl_radToDeg(fAngleRad) );
double fAngleDeg = NormAngle360(lcl_radToDeg(fAngleRad));
if( fAngleDeg > 180 ) // in case the wrong angle has been computed
fAngleDeg = 360 - fAngleDeg;
SAL_INFO( "chart2.pie.label.bestfit.inside",
@@ -1522,7 +1513,7 @@
{
// check the angle between CP and CN
fAngleRad = aPositionalVector.angle(aNearestVertex);
fAngleDeg = lcl_getDegAngleInStandardRange( lcl_radToDeg(fAngleRad) );
fAngleDeg = NormAngle360(lcl_radToDeg(fAngleRad));
if( fAngleDeg > 180 ) // in case the wrong angle has been computed
fAngleDeg = 360 - fAngleDeg;
SAL_INFO( "chart2.pie.label.bestfit.inside",
@@ -1536,7 +1527,7 @@
{
// check the angle between CP and CG
fAngleRad = aPositionalVector.angle(aVertexG);
fAngleDeg = lcl_getDegAngleInStandardRange( lcl_radToDeg(fAngleRad) );
fAngleDeg = NormAngle360(lcl_radToDeg(fAngleRad));
if( fAngleDeg > 180 ) // in case the wrong angle has been computed
fAngleDeg = 360 - fAngleDeg;
SAL_INFO( "chart2.pie.label.bestfit.inside",
diff --git a/chart2/source/view/main/AbstractShapeFactory.cxx b/chart2/source/view/main/AbstractShapeFactory.cxx
index df2516a..6e85eb7 100644
--- a/chart2/source/view/main/AbstractShapeFactory.cxx
+++ b/chart2/source/view/main/AbstractShapeFactory.cxx
@@ -32,6 +32,7 @@
#include <editeng/unoprnms.hxx>
#include <rtl/math.hxx>
#include <tools/helpers.hxx>
#include <tools/svlibrary.h>
#include <svx/svdocirc.hxx>
#include <svx/svdopath.hxx>
@@ -262,10 +263,7 @@
aRet = aSize;
else
{
while(fRotationAngleDegree>=360.0)
fRotationAngleDegree-=360.0;
while(fRotationAngleDegree<0.0)
fRotationAngleDegree+=360.0;
fRotationAngleDegree = NormAngle360(fRotationAngleDegree);
if(fRotationAngleDegree>270.0)
fRotationAngleDegree=360.0-fRotationAngleDegree;
else if(fRotationAngleDegree>180.0)
diff --git a/chart2/source/view/main/PlottingPositionHelper.cxx b/chart2/source/view/main/PlottingPositionHelper.cxx
index 9ad4f44..da5cc41 100644
--- a/chart2/source/view/main/PlottingPositionHelper.cxx
+++ b/chart2/source/view/main/PlottingPositionHelper.cxx
@@ -34,6 +34,7 @@
#include <com/sun/star/drawing/XShapes.hpp>
#include <rtl/math.hxx>
#include <tools/helpers.hxx>
namespace chart
{
@@ -477,11 +478,7 @@
fRet = m_fAngleDegreeOffset
+ fAxisAngleScaleDirection*(fScaledLogicAngleValue-MinAngleValue)*360.0
/fabs(MaxAngleValue-MinAngleValue);
while(fRet>360.0)
fRet-=360.0;
while(fRet<0)
fRet+=360.0;
return fRet;
return NormAngle360(fRet);
}
/**
diff --git a/chart2/source/view/main/PolarLabelPositionHelper.cxx b/chart2/source/view/main/PolarLabelPositionHelper.cxx
index 052994c..07bf9e8 100644
--- a/chart2/source/view/main/PolarLabelPositionHelper.cxx
+++ b/chart2/source/view/main/PolarLabelPositionHelper.cxx
@@ -25,6 +25,8 @@
#include <com/sun/star/chart/DataLabelPlacement.hpp>
#include <tools/helpers.hxx>
namespace chart
{
using namespace ::com::sun::star;
@@ -122,10 +124,7 @@
//set LabelAlignment
if( !bCenter )
{
while(fAngleDegree>360.0)
fAngleDegree-=360.0;
while(fAngleDegree<0.0)
fAngleDegree+=360.0;
fAngleDegree = NormAngle360(fAngleDegree);
bool bOutside = nLabelPlacement == css::chart::DataLabelPlacement::OUTSIDE;
diff --git a/chart2/source/view/main/ShapeFactory.cxx b/chart2/source/view/main/ShapeFactory.cxx
index 8e3f67b..696ca39 100644
--- a/chart2/source/view/main/ShapeFactory.cxx
+++ b/chart2/source/view/main/ShapeFactory.cxx
@@ -59,6 +59,7 @@
#include <basegfx/point/b2dpoint.hxx>
#include <basegfx/matrix/b3dhommatrix.hxx>
#include <tools/diagnose_ex.h>
#include <tools/helpers.hxx>
#include <sal/log.hxx>
#include <algorithm>
@@ -877,10 +878,7 @@
if( !xTarget.is() )
return nullptr;
while(fUnitCircleWidthAngleDegree>360)
fUnitCircleWidthAngleDegree -= 360.0;
while(fUnitCircleWidthAngleDegree<0)
fUnitCircleWidthAngleDegree += 360.0;
fUnitCircleWidthAngleDegree = NormAngle360(fUnitCircleWidthAngleDegree);
//create shape
uno::Reference< drawing::XShape > xShape(
diff --git a/filter/source/graphicfilter/icgm/actimpr.cxx b/filter/source/graphicfilter/icgm/actimpr.cxx
index c685ce5..daa20e4 100644
--- a/filter/source/graphicfilter/icgm/actimpr.cxx
+++ b/filter/source/graphicfilter/icgm/actimpr.cxx
@@ -45,6 +45,7 @@
#include <comphelper/processfactory.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <tools/helpers.hxx>
#include <vcl/gradient.hxx>
#include "main.hxx"
@@ -496,12 +497,8 @@
if ( rOrientation != 0 )
{
fStartAngle += rOrientation;
if ( fStartAngle >= 360 )
fStartAngle -= 360;
fEndAngle += rOrientation;
if ( fEndAngle >= 360 )
fEndAngle -= 360;
fStartAngle = NormAngle360(fStartAngle + rOrientation);
fEndAngle = NormAngle360(fEndAngle + rOrientation);
}
switch( nType )
{
diff --git a/filter/source/graphicfilter/idxf/dxf2mtf.cxx b/filter/source/graphicfilter/idxf/dxf2mtf.cxx
index 4059557..50a9882 100644
--- a/filter/source/graphicfilter/idxf/dxf2mtf.cxx
+++ b/filter/source/graphicfilter/idxf/dxf2mtf.cxx
@@ -192,7 +192,7 @@
vcl::Font aFont;
nAngle=-nAngle;
while (nAngle>3600) nAngle-=3600;
while (nAngle>=3600) nAngle-=3600;
while (nAngle<0) nAngle+=3600;
nColor=GetEntityColor(rE);
diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx
index 0540c70..6bd7638 100644
--- a/filter/source/msfilter/escherex.cxx
+++ b/filter/source/msfilter/escherex.cxx
@@ -2048,10 +2048,7 @@
void lcl_Rotate(sal_Int32 nAngle, Point center, Point& pt)
{
while ( nAngle<0)
nAngle +=36000;
while (nAngle>=36000)
nAngle -=36000;
nAngle = NormAngle36000(nAngle);
int cs, sn;
switch (nAngle)
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index c232ee0..ff3df05 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -371,7 +371,7 @@
if ( nContent )
{
nAngle = ( static_cast<sal_Int16>( nContent >> 16) * 100L ) + ( ( ( nContent & 0x0000ffff) * 100L ) >> 16 );
nAngle = NormAngle360( -nAngle );
nAngle = NormAngle36000( -nAngle );
}
return nAngle;
}
@@ -4567,7 +4567,7 @@
{
double fNumber;
seqAdjustmentValues[ 0 ].Value >>= fNumber;
nEndAngle = NormAngle360( - static_cast<sal_Int32>(fNumber) * 100 );
nEndAngle = NormAngle36000( - static_cast<sal_Int32>(fNumber) * 100 );
}
else
{
@@ -4583,7 +4583,7 @@
fNumber = atan2( double( aStartPt.X() - cent.X() ),double( aStartPt.Y() - cent.Y() ) )+ F_PI; // 0..2PI
fNumber /= F_PI180; // 0..360.0
}
nEndAngle = NormAngle360( - static_cast<sal_Int32>(fNumber) * 100 );
nEndAngle = NormAngle36000( - static_cast<sal_Int32>(fNumber) * 100 );
seqAdjustmentValues[ 0 ].Value <<= fNumber;
seqAdjustmentValues[ 0 ].State = css::beans::PropertyState_DIRECT_VALUE; // so this value will properly be stored
}
@@ -4592,7 +4592,7 @@
{
double fNumber;
seqAdjustmentValues[ 1 ].Value >>= fNumber;
nStartAngle = NormAngle360( - static_cast<sal_Int32>(fNumber) * 100 );
nStartAngle = NormAngle36000( - static_cast<sal_Int32>(fNumber) * 100 );
}
else
{
diff --git a/include/svx/svdtrans.hxx b/include/svx/svdtrans.hxx
index 89b29d4..7ddb2e1 100644
--- a/include/svx/svdtrans.hxx
+++ b/include/svx/svdtrans.hxx
@@ -164,9 +164,9 @@
*/
SVX_DLLPUBLIC long GetAngle(const Point& rPnt);
long NormAngle180(long a); /// Normalize angle to -180.00..179.99
long NormAngle18000(long a); /// Normalize angle to -180.00..179.99
SVX_DLLPUBLIC long NormAngle360(long a); /// Normalize angle to 0.00..359.99
SVX_DLLPUBLIC long NormAngle36000(long a); /// Normalize angle to 0.00..359.99
sal_uInt16 GetAngleSector(long nAngle); /// Determine sector within the cartesian coordinate system
diff --git a/include/tools/helpers.hxx b/include/tools/helpers.hxx
index da815e1..bbe350d 100644
--- a/include/tools/helpers.hxx
+++ b/include/tools/helpers.hxx
@@ -76,6 +76,26 @@
return fVal > 0.0 ? static_cast<long>( fVal + 0.5 ) : -static_cast<long>( -fVal + 0.5 );
}
//valid range: (-180,180]
template <typename T> inline SAL_WARN_UNUSED_RESULT T NormAngle180(T angle)
{
while (angle <= -180)
angle += 360;
while (angle > 180)
angle -= 360;
return angle;
}
//valid range: [0,360)
template <typename T> inline SAL_WARN_UNUSED_RESULT T NormAngle360(T angle)
{
while (angle < 0)
angle += 360;
while (angle >= 360)
angle -= 360;
return angle;
}
/** Convert 100th-mm to twips
A twip is 1/20 of a point, one inch is equal to 72 points, and
diff --git a/oox/source/drawingml/chart/plotareaconverter.cxx b/oox/source/drawingml/chart/plotareaconverter.cxx
index d9755fd..c562ea8 100644
--- a/oox/source/drawingml/chart/plotareaconverter.cxx
+++ b/oox/source/drawingml/chart/plotareaconverter.cxx
@@ -35,6 +35,7 @@
#include <oox/token/namespaces.hxx>
#include <oox/token/properties.hxx>
#include <oox/token/tokens.hxx>
#include <tools/helpers.hxx>
namespace oox {
namespace drawingml {
@@ -234,8 +235,7 @@
}
// Y rotation (map OOXML [0..359] to Chart2 [-179,180])
nRotationY %= 360;
if( nRotationY > 180 ) nRotationY -= 360;
nRotationY = NormAngle180(nRotationY);
/* Perspective (map OOXML [0..200] to Chart2 [0,100]). Seems that MSO 2007 is
buggy here, the XML plugin of MSO 2003 writes the correct perspective in
the range from 0 to 100. We will emulate the wrong behaviour of MSO 2007. */
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index f9b3abd..70028b3 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -461,7 +461,7 @@
int nIndex = 0;
for (auto& aEntry : aGdList)
{
double fAngle = NormAngle360( aEntry.maFormula.toDouble() / -600.0 );
double fAngle = NormAngle36000( aEntry.maFormula.toDouble() / -600.0 );
fAngle = 360.0 - fAngle / 100.0;
aAdjustment[nIndex].Value <<= fAngle;
@@ -1318,7 +1318,7 @@
if ( !bUseRotationTransform && mnRotation != 0 )
{
// use the same logic for rotation from VML exporter (SimpleShape::implConvertAndInsert at vmlshape.cxx)
aPropertySet.setAnyProperty( PROP_RotateAngle, makeAny( sal_Int32( NormAngle360( mnRotation / -600 ) ) ) );
aPropertySet.setAnyProperty( PROP_RotateAngle, makeAny( sal_Int32( NormAngle36000( mnRotation / -600 ) ) ) );
aPropertySet.setAnyProperty( PROP_HoriOrientPosition, makeAny( maPosition.X ) );
aPropertySet.setAnyProperty( PROP_VertOrientPosition, makeAny( maPosition.Y ) );
}
diff --git a/oox/source/shape/WpsContext.cxx b/oox/source/shape/WpsContext.cxx
index d0d021c..a5ed731 100644
--- a/oox/source/shape/WpsContext.cxx
+++ b/oox/source/shape/WpsContext.cxx
@@ -105,7 +105,7 @@
// If the text is not rotated the way the shape wants it already, set the angle.
const sal_Int32 nRotation = -270;
if (static_cast<long>(basegfx::rad2deg(fRotate)) != NormAngle360(static_cast<long>(nRotation) * 100) / 100)
if (static_cast<long>(basegfx::rad2deg(fRotate)) != NormAngle36000(static_cast<long>(nRotation) * 100) / 100)
{
comphelper::SequenceAsHashMap aCustomShapeGeometry(xPropertySet->getPropertyValue("CustomShapeGeometry"));
aCustomShapeGeometry["TextPreRotateAngle"] <<= nRotation;
diff --git a/oox/source/vml/vmlformatting.cxx b/oox/source/vml/vmlformatting.cxx
index c48b386..d2132c0 100644
--- a/oox/source/vml/vmlformatting.cxx
+++ b/oox/source/vml/vmlformatting.cxx
@@ -135,7 +135,7 @@
return 0;
}
return NormAngle360(fRotation * -100);
return NormAngle36000(fRotation * -100);
}
sal_Int64 ConversionHelper::decodeMeasureToEmu( const GraphicHelper& rGraphicHelper,
diff --git a/sc/source/filter/excel/xichart.cxx b/sc/source/filter/excel/xichart.cxx
index c42abc3..a3062d2 100644
--- a/sc/source/filter/excel/xichart.cxx
+++ b/sc/source/filter/excel/xichart.cxx
@@ -81,6 +81,7 @@
#include <svx/svdpage.hxx>
#include <svx/unoapi.hxx>
#include <sal/log.hxx>
#include <tools/helpers.hxx>
#include <document.hxx>
#include <drwlayer.hxx>
@@ -2430,8 +2431,7 @@
if( b3dWallChart )
{
// Y rotation (Excel [0..359], Chart2 [-179,180])
nRotationY = maData.mnRotation % 360;
if( nRotationY > 180 ) nRotationY -= 360;
nRotationY = NormAngle180(maData.mnRotation);
// X rotation a.k.a. elevation (Excel [-90..90], Chart2 [-179,180])
nRotationX = limit_cast< sal_Int32, sal_Int32 >( maData.mnElevation, -90, 90 );
// perspective (Excel and Chart2 [0,100])
diff --git a/sd/source/ui/func/fusel.cxx b/sd/source/ui/func/fusel.cxx
index 84fcea4..c934d50 100644
--- a/sd/source/ui/func/fusel.cxx
+++ b/sd/source/ui/func/fusel.cxx
@@ -178,7 +178,7 @@
long nAngle0 = GetAngle(aMDPos - mpView->GetRef1());
nAngle0 -= 27000;
nAngle0 = NormAngle360(nAngle0);
nAngle0 = NormAngle36000(nAngle0);
bMirrorSide0 = nAngle0 < 18000;
if (!pHdl && mpView->Is3DRotationCreationActive())
@@ -740,7 +740,7 @@
**********************************************************/
long nAngle1 = GetAngle(aPnt - mpView->GetRef1());
nAngle1 -= 27000;
nAngle1 = NormAngle360(nAngle1);
nAngle1 = NormAngle36000(nAngle1);
bool bMirrorSide1 = nAngle1 < 18000;
if (bMirrorSide0 != bMirrorSide1)
diff --git a/svx/source/dialog/dlgctl3d.cxx b/svx/source/dialog/dlgctl3d.cxx
index 9f96d62..1e6fa863c 100644
--- a/svx/source/dialog/dlgctl3d.cxx
+++ b/svx/source/dialog/dlgctl3d.cxx
@@ -37,6 +37,7 @@
#include <helpids.h>
#include <algorithm>
#include <svx/dialmgr.hxx>
#include <tools/helpers.hxx>
#include <vcl/settings.hxx>
using namespace com::sun::star;
@@ -671,15 +672,7 @@
double fNewPosVer = mfSaveActionStartVer - static_cast<double>(aDeltaPos.Y());
// cut horizontal
while(fNewPosHor < 0.0)
{
fNewPosHor += 360.0;
}
while(fNewPosHor >= 360.0)
{
fNewPosHor -= 360.0;
}
fNewPosHor = NormAngle360(fNewPosHor);
// cut vertical
if(fNewPosVer < -90.0)
diff --git a/svx/source/engine3d/dragmt3d.cxx b/svx/source/engine3d/dragmt3d.cxx
index 255b667..6052a6d 100644
--- a/svx/source/engine3d/dragmt3d.cxx
+++ b/svx/source/engine3d/dragmt3d.cxx
@@ -341,7 +341,7 @@
if(E3dDragConstraint::Z == meConstraint)
{
fWAngle = NormAngle360(GetAngle(rPnt - DragStat().GetRef1()) -
fWAngle = NormAngle36000(GetAngle(rPnt - DragStat().GetRef1()) -
rCandidate.mnStartAngle) - rCandidate.mnLastAngle;
rCandidate.mnLastAngle = static_cast<long>(fWAngle) + rCandidate.mnLastAngle;
fWAngle /= 100.0;
diff --git a/svx/source/svdraw/svddrgmt.cxx b/svx/source/svdraw/svddrgmt.cxx
index 2bc2c74..d826a2f 100644
--- a/svx/source/svdraw/svddrgmt.cxx
+++ b/svx/source/svdraw/svddrgmt.cxx
@@ -1037,12 +1037,12 @@
if (pH!=nullptr)
{
Point aRef(pH->GetPos());
long nAngle=NormAngle360(GetAngle(aPnt-aRef));
long nAngle=NormAngle36000(GetAngle(aPnt-aRef));
long nNewAngle=nAngle;
nNewAngle+=nSA/2;
nNewAngle/=nSA;
nNewAngle*=nSA;
nNewAngle=NormAngle360(nNewAngle);
nNewAngle=NormAngle36000(nNewAngle);
double a=(nNewAngle-nAngle)*nPi180;
double nSin=sin(a);
double nCos=cos(a);
@@ -2061,7 +2061,7 @@
{
ImpTakeDescriptionStr(STR_DragMethRotate, rStr);
rStr += " (";
sal_Int32 nTmpAngle(NormAngle360(nAngle));
sal_Int32 nTmpAngle(NormAngle36000(nAngle));
if(bRight && nAngle)
{
@@ -2114,7 +2114,7 @@
Point aPnt(rPnt_);
if (DragStat().CheckMinMoved(aPnt))
{
long nNewAngle=NormAngle360(GetAngle(aPnt-DragStat().GetRef1())-nAngle0);
long nNewAngle=NormAngle36000(GetAngle(aPnt-DragStat().GetRef1())-nAngle0);
long nSA=0;
if (getSdrDragView().IsAngleSnapEnabled())
@@ -2130,7 +2130,7 @@
nNewAngle*=nSA;
}
nNewAngle=NormAngle180(nNewAngle);
nNewAngle=NormAngle18000(nNewAngle);
if (nAngle!=nNewAngle)
{
@@ -2207,7 +2207,7 @@
if(bUpSideDown)
nTmpAngle += 18000;
nTmpAngle = NormAngle180(nTmpAngle);
nTmpAngle = NormAngle18000(nTmpAngle);
rStr += SdrModel::GetAngleString(nTmpAngle) + ")";
@@ -2305,20 +2305,20 @@
if (bSlant)
{
nNewAngle=NormAngle180(-(GetAngle(aDif)-nAngle0));
nNewAngle=NormAngle18000(-(GetAngle(aDif)-nAngle0));
if (bVertical)
nNewAngle=NormAngle180(-nNewAngle);
nNewAngle=NormAngle18000(-nNewAngle);
}
else
{
if (bVertical)
nNewAngle=NormAngle180(GetAngle(aDif));
nNewAngle=NormAngle18000(GetAngle(aDif));
else
nNewAngle=NormAngle180(-(GetAngle(aDif)-9000));
nNewAngle=NormAngle18000(-(GetAngle(aDif)-9000));
if (nNewAngle<-9000 || nNewAngle>9000)
nNewAngle=NormAngle180(nNewAngle+18000);
nNewAngle=NormAngle18000(nNewAngle+18000);
if (bResize)
{
@@ -2350,7 +2350,7 @@
nNewAngle*=nSA;
}
nNewAngle=NormAngle360(nNewAngle);
nNewAngle=NormAngle36000(nNewAngle);
bUpSideDown=nNewAngle>9000 && nNewAngle<27000;
if (bSlant)
@@ -2480,7 +2480,7 @@
{
long nAngle1=GetAngle(rPnt-DragStat().GetRef1());
nAngle1-=nAngle;
nAngle1=NormAngle360(nAngle1);
nAngle1=NormAngle36000(nAngle1);
return nAngle1<18000;
}
@@ -2514,7 +2514,7 @@
aDif=pH2->GetPos()-pH1->GetPos();
bool b90=(aDif.X()==0) || aDif.Y()==0;
bool b45=b90 || (std::abs(aDif.X()) == std::abs(aDif.Y()));
nAngle=NormAngle360(GetAngle(aDif));
nAngle=NormAngle36000(GetAngle(aDif));
if (!getSdrDragView().IsMirrorAllowed() && !b45)
return false; // free choice of axis angle not allowed
@@ -3163,13 +3163,13 @@
if (bLwr) nPntWink+=18000;
}
nPntWink=NormAngle360(nPntWink);
nPntWink=NormAngle36000(nPntWink);
}
else
{
if (nNewRad<0) nPntWink+=18000;
if (bVertical) nPntWink=18000-nPntWink;
nPntWink=NormAngle180(nPntWink);
nPntWink=NormAngle18000(nPntWink);
nPntWink = std::abs(nPntWink);
}
@@ -3177,7 +3177,7 @@
if (bResize)
{
long nMul=static_cast<long>(nUmfang*NormAngle360(nPntWink)/36000);
long nMul=static_cast<long>(nUmfang*NormAngle36000(nPntWink)/36000);
if (bAtCenter)
nMul*=2;
diff --git a/svx/source/svdraw/svdglue.cxx b/svx/source/svdraw/svdglue.cxx
index cb253b1..477f97d 100644
--- a/svx/source/svdraw/svdglue.cxx
+++ b/svx/source/svdraw/svdglue.cxx
@@ -149,7 +149,7 @@
void SdrGluePoint::SetAlignAngle(long nAngle)
{
nAngle=NormAngle360(nAngle);
nAngle=NormAngle36000(nAngle);
if (nAngle>=33750 || nAngle<2250) nAlign=SdrAlign::HORZ_RIGHT |SdrAlign::VERT_CENTER;
else if (nAngle< 6750) nAlign=SdrAlign::HORZ_RIGHT |SdrAlign::VERT_TOP ;
else if (nAngle<11250) nAlign=SdrAlign::HORZ_CENTER|SdrAlign::VERT_TOP ;
@@ -174,7 +174,7 @@
SdrEscapeDirection SdrGluePoint::EscAngleToDir(long nAngle)
{
nAngle=NormAngle360(nAngle);
nAngle=NormAngle36000(nAngle);
if (nAngle>=31500 || nAngle<4500)
return SdrEscapeDirection::RIGHT;
if (nAngle<13500)
diff --git a/svx/source/svdraw/svdhdl.cxx b/svx/source/svdraw/svdhdl.cxx
index 7143327..68052c1 100644
--- a/svx/source/svdraw/svdhdl.cxx
+++ b/svx/source/svdraw/svdhdl.cxx
@@ -979,9 +979,8 @@
default:
break;
}
nHdlAngle+=nRotationAngle+2249; // a little bit more (for rounding)
while (nHdlAngle<0) nHdlAngle+=36000;
while (nHdlAngle>=36000) nHdlAngle-=36000;
// a little bit more (for rounding)
nHdlAngle = NormAngle36000(nHdlAngle + nRotationAngle + 2249);
nHdlAngle/=4500;
switch (static_cast<sal_uInt8>(nHdlAngle)) {
case 0: ePtr=PointerStyle::ESize; break;
diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx
index 2c261b5..8d839ab 100644
--- a/svx/source/svdraw/svdoashp.cxx
+++ b/svx/source/svdraw/svdoashp.cxx
@@ -2951,7 +2951,7 @@
// #i78696#
// fRotate is mathematically correct, but aGeoStat.nRotationAngle is
// mirrored -> mirror value here
aGeoStat.nRotationAngle = NormAngle360(FRound(-fRotate / F_PI18000));
aGeoStat.nRotationAngle = NormAngle36000(FRound(-fRotate / F_PI18000));
aGeoStat.RecalcSinCos();
Rotate(Point(), aGeoStat.nRotationAngle, aGeoStat.nSin, aGeoStat.nCos);
}
diff --git a/svx/source/svdraw/svdocirc.cxx b/svx/source/svdraw/svdocirc.cxx
index 0cdaeef..cbe1ce8 100644
--- a/svx/source/svdraw/svdocirc.cxx
+++ b/svx/source/svdraw/svdocirc.cxx
@@ -137,8 +137,8 @@
: SdrRectObj(rSdrModel, rRect)
{
long nAngleDif=nNewEndWink-nNewStartWink;
nStartAngle=NormAngle360(nNewStartWink);
nEndAngle=NormAngle360(nNewEndWink);
nStartAngle=NormAngle36000(nNewStartWink);
nEndAngle=NormAngle36000(nNewEndWink);
if (nAngleDif==36000) nEndAngle+=nAngleDif; // full circle
meCircleKind=eNewKind;
bClosedObj=eNewKind!=OBJ_CARC;
@@ -536,7 +536,7 @@
aPt.setX(BigMulDiv(aPt.X(),nHgt,nWdt) );
}
long nAngle=NormAngle360(GetAngle(aPt));
long nAngle=NormAngle36000(GetAngle(aPt));
if (rDrag.GetView() && rDrag.GetView()->IsAngleSnapEnabled())
{
@@ -547,7 +547,7 @@
nAngle+=nSA/2;
nAngle/=nSA;
nAngle*=nSA;
nAngle=NormAngle360(nAngle);
nAngle=NormAngle36000(nAngle);
}
}
@@ -649,14 +649,14 @@
} else {
if (nWdt!=0) aP.setX(aP.X()*nHgt/nWdt );
}
nStart=NormAngle360(GetAngle(aP));
nStart=NormAngle36000(GetAngle(aP));
if (rStat.GetView()!=nullptr && rStat.GetView()->IsAngleSnapEnabled()) {
long nSA=rStat.GetView()->GetSnapAngle();
if (nSA!=0) { // angle snapping
nStart+=nSA/2;
nStart/=nSA;
nStart*=nSA;
nStart=NormAngle360(nStart);
nStart=NormAngle36000(nStart);
}
}
aP1 = GetAnglePnt(aR,nStart);
@@ -670,14 +670,14 @@
} else {
aP.setX(BigMulDiv(aP.X(),nHgt,nWdt) );
}
nEnd=NormAngle360(GetAngle(aP));
nEnd=NormAngle36000(GetAngle(aP));
if (rStat.GetView()!=nullptr && rStat.GetView()->IsAngleSnapEnabled()) {
long nSA=rStat.GetView()->GetSnapAngle();
if (nSA!=0) { // angle snapping
nEnd+=nSA/2;
nEnd/=nSA;
nEnd*=nSA;
nEnd=NormAngle360(nEnd);
nEnd=NormAngle36000(nEnd);
}
}
aP2 = GetAnglePnt(aR,nEnd);
@@ -862,8 +862,8 @@
}
}
long nAngleDif=nE0-nS0;
nStartAngle=NormAngle360(nS0);
nEndAngle =NormAngle360(nE0);
nStartAngle=NormAngle36000(nS0);
nEndAngle =NormAngle36000(nE0);
if (nAngleDif==36000) nEndAngle+=nAngleDif; // full circle
}
}
@@ -931,8 +931,8 @@
nStartAngle=GetAngle(aTmpPt2);
nEndAngle =GetAngle(aTmpPt1);
long nAngleDif=nEndAngle-nStartAngle;
nStartAngle=NormAngle360(nStartAngle);
nEndAngle =NormAngle360(nEndAngle);
nStartAngle=NormAngle36000(nStartAngle);
nEndAngle =NormAngle36000(nEndAngle);
if (nAngleDif==36000) nEndAngle+=nAngleDif; // full circle
}
SetXPolyDirty();
diff --git a/svx/source/svdraw/svdomeas.cxx b/svx/source/svdraw/svdomeas.cxx
index e2420e7..24943f0 100644
--- a/svx/source/svdraw/svdomeas.cxx
+++ b/svx/source/svdraw/svdomeas.cxx
@@ -431,7 +431,7 @@
rPol.bAutoUpsideDown=false;
if (rRec.bTextAutoAngle) {
long nTmpAngle=NormAngle360(rPol.nTextAngle-rRec.nTextAutoAngleView);
long nTmpAngle=NormAngle36000(rPol.nTextAngle-rRec.nTextAutoAngleView);
if (nTmpAngle>=18000) {
rPol.nTextAngle+=18000;
rPol.bAutoUpsideDown=true;
@@ -439,10 +439,10 @@
}
if (rRec.bTextUpsideDown) rPol.nTextAngle+=18000;
rPol.nTextAngle=NormAngle360(rPol.nTextAngle);
rPol.nTextAngle=NormAngle36000(rPol.nTextAngle);
rPol.nHlpAngle=rPol.nLineAngle+9000;
if (rRec.bBelowRefEdge) rPol.nHlpAngle+=18000;
rPol.nHlpAngle=NormAngle360(rPol.nHlpAngle);
rPol.nHlpAngle=NormAngle36000(rPol.nHlpAngle);
double nHlpSin=nLineCos;
double nHlpCos=-nLineSin;
if (rRec.bBelowRefEdge) {
diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx
index 5173a9f..0b8243e 100644
--- a/svx/source/svdraw/svdopath.cxx
+++ b/svx/source/svdraw/svdopath.cxx
@@ -315,8 +315,8 @@
long dx=rP2.X()-rP1.X();
long dy=rP2.Y()-rP1.Y();
long dAngle=GetAngle(Point(dx,dy))-nTangAngle;
dAngle=NormAngle360(dAngle);
long nTmpAngle=NormAngle360(9000-dAngle);
dAngle=NormAngle36000(dAngle);
long nTmpAngle=NormAngle36000(9000-dAngle);
bool bRet=nTmpAngle!=9000 && nTmpAngle!=27000;
long nRad=0;
if (bRet) {
@@ -325,13 +325,13 @@
nRad=std::abs(FRound(nR));
}
if (dAngle<18000) {
nCircStAngle=NormAngle360(nTangAngle-9000);
nCircRelAngle=NormAngle360(2*dAngle);
nCircStAngle=NormAngle36000(nTangAngle-9000);
nCircRelAngle=NormAngle36000(2*dAngle);
aCircCenter.AdjustX(FRound(nRad*cos((nTangAngle+9000)*nPi180)) );
aCircCenter.AdjustY( -(FRound(nRad*sin((nTangAngle+9000)*nPi180))) );
} else {
nCircStAngle=NormAngle360(nTangAngle+9000);
nCircRelAngle=-NormAngle360(36000-2*dAngle);
nCircStAngle=NormAngle36000(nTangAngle+9000);
nCircRelAngle=-NormAngle36000(36000-2*dAngle);
aCircCenter.AdjustX(FRound(nRad*cos((nTangAngle-9000)*nPi180)) );
aCircCenter.AdjustY( -(FRound(nRad*sin((nTangAngle-9000)*nPi180))) );
}
@@ -344,7 +344,7 @@
nCircRelAngle+=nSA/2;
nCircRelAngle/=nSA;
nCircRelAngle*=nSA;
nCircRelAngle=NormAngle360(nCircRelAngle);
nCircRelAngle=NormAngle36000(nCircRelAngle);
if (bNeg) nCircRelAngle=-nCircRelAngle;
}
}
@@ -363,7 +363,7 @@
return aXP;
} else {
XPolygon aXP(aCircCenter,nCircRadius,nCircRadius,
sal_uInt16(NormAngle360(nCircStAngle+nCircRelAngle+5)/10),sal_uInt16((nCircStAngle+5)/10),false);
sal_uInt16(NormAngle36000(nCircStAngle+nCircRelAngle+5)/10),sal_uInt16((nCircStAngle+5)/10),false);
sal_uInt16 nCount=aXP.GetPointCount();
for (sal_uInt16 nNum=nCount/2; nNum>0;) {
nNum--; // reverse XPoly's order of points
@@ -2982,7 +2982,7 @@
// #i78696#
// fRotate is mathematically correct, but aGeoStat.nRotationAngle is
// mirrored -> mirror value here
aGeo.nRotationAngle = NormAngle360(FRound(-fRotate / F_PI18000));
aGeo.nRotationAngle = NormAngle36000(FRound(-fRotate / F_PI18000));
aGeo.RecalcSinCos();
}
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx
index a7e706d..54fcda6 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -1703,7 +1703,7 @@
// #i78696#
// fRotate is matematically correct, but aGeoStat.nRotationAngle is
// mirrored -> mirror value here
aGeoStat.nRotationAngle = NormAngle360(FRound(-fRotate / F_PI18000));
aGeoStat.nRotationAngle = NormAngle36000(FRound(-fRotate / F_PI18000));
aGeoStat.RecalcSinCos();
Rotate(Point(), aGeoStat.nRotationAngle, aGeoStat.nSin, aGeoStat.nCos);
}
diff --git a/svx/source/svdraw/svdotxtr.cxx b/svx/source/svdraw/svdotxtr.cxx
index b2b3afd..91c294e 100644
--- a/svx/source/svdraw/svdotxtr.cxx
+++ b/svx/source/svdraw/svdotxtr.cxx
@@ -156,7 +156,7 @@
if (bRota90Merk) {
bool bRota90=aGeo.nRotationAngle % 9000 ==0;
if (!bRota90) { // there's seems to be a rounding error occurring: correct it
long a=NormAngle360(aGeo.nRotationAngle);
long a=NormAngle36000(aGeo.nRotationAngle);
if (a<4500) a=0;
else if (a<13500) a=9000;
else if (a<22500) a=18000;
@@ -196,11 +196,11 @@
maRect.SetRight(maRect.Left()+dx );
maRect.SetBottom(maRect.Top()+dy );
if (aGeo.nRotationAngle==0) {
aGeo.nRotationAngle=NormAngle360(nAngle);
aGeo.nRotationAngle=NormAngle36000(nAngle);
aGeo.nSin=sn;
aGeo.nCos=cs;
} else {
aGeo.nRotationAngle=NormAngle360(aGeo.nRotationAngle+nAngle);
aGeo.nRotationAngle=NormAngle36000(aGeo.nRotationAngle+nAngle);
aGeo.RecalcSinCos();
}
SetRectsDirty();
@@ -258,7 +258,7 @@
if (bRota90Merk) {
bool bRota90=aGeo.nRotationAngle % 9000 ==0;
if (bRota90Merk && !bRota90) { // there's seems to be a rounding error occurring: correct it
long a=NormAngle360(aGeo.nRotationAngle);
long a=NormAngle36000(aGeo.nRotationAngle);
if (a<4500) a=0;
else if (a<13500) a=9000;
else if (a<22500) a=18000;
diff --git a/svx/source/svdraw/svdtrans.cxx b/svx/source/svdraw/svdtrans.cxx
index c9e7326..34bb939 100644
--- a/svx/source/svdraw/svdtrans.cxx
+++ b/svx/source/svdraw/svdtrans.cxx
@@ -394,14 +394,14 @@
return a;
}
long NormAngle180(long a)
long NormAngle18000(long a)
{
while (a<-18000) a+=36000;
while (a>=18000) a-=36000;
return a;
}
long NormAngle360(long a)
long NormAngle36000(long a)
{
while (a<0) a+=36000;
while (a>=36000) a-=36000;
@@ -483,7 +483,7 @@
void Poly2Rect(const tools::Polygon& rPol, tools::Rectangle& rRect, GeoStat& rGeo)
{
rGeo.nRotationAngle=GetAngle(rPol[1]-rPol[0]);
rGeo.nRotationAngle=NormAngle360(rGeo.nRotationAngle);
rGeo.nRotationAngle=NormAngle36000(rGeo.nRotationAngle);
// rotation successful
rGeo.RecalcSinCos();
@@ -507,9 +507,9 @@
nShW+=18000;
aPt0=rPol[3];
}
nShW=NormAngle180(nShW);
nShW=NormAngle18000(nShW);
if (nShW<-9000 || nShW>9000) {
nShW=NormAngle180(nShW+18000);
nShW=NormAngle18000(nShW+18000);
}
if (nShW<-SDRMAXSHEAR) nShW=-SDRMAXSHEAR; // limit ShearWinkel (shear angle) to +/- 89.00 deg
if (nShW>SDRMAXSHEAR) nShW=SDRMAXSHEAR;
diff --git a/sw/source/core/graphic/grfatr.cxx b/sw/source/core/graphic/grfatr.cxx
index a9b318a..4b73f2e 100644
--- a/sw/source/core/graphic/grfatr.cxx
+++ b/sw/source/core/graphic/grfatr.cxx
@@ -155,7 +155,7 @@
DBG_ASSERT(false, "SwRotationGrf: Value is in 10th degree and *has* to be in [0 .. 3600[ (!)");
return 3600 + (nValue % 3600);
}
else if (nValue > 3600)
else if (nValue >= 3600)
{
// bigger range, use modulo
DBG_ASSERT(false, "SwRotationGrf: Value is in 10th degree and *has* to be in [0 .. 3600[ (!)");
diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx
index 9b1040d..98ec36f 100644
--- a/sw/source/filter/ww8/wrtw8esh.cxx
+++ b/sw/source/filter/ww8/wrtw8esh.cxx
@@ -689,7 +689,7 @@
aRect = pObj->GetLogicRect();
// rotating to vertical means swapping height and width as seen in SvxMSDffManager::ImportShape
const long nAngle = NormAngle360( pObj->GetRotateAngle() );
const long nAngle = NormAngle36000( pObj->GetRotateAngle() );
const bool bAllowSwap = pObj->GetObjIdentifier() != OBJ_LINE && pObj->GetObjIdentifier() != OBJ_GRUP;
if ( bAllowSwap && (( nAngle > 4500 && nAngle <= 13500 ) || ( nAngle > 22500 && nAngle <= 31500 )) )
{
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index ae8a633..2c0c1a6 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -248,7 +248,7 @@
if (!xServiceInfo->supportsService("com.sun.star.text.TextFrame"))
xPropertySet->setPropertyValue(
"RotateAngle",
uno::makeAny(sal_Int32(NormAngle360(static_cast<long>(nRotation) * -1))));
uno::makeAny(sal_Int32(NormAngle36000(static_cast<long>(nRotation) * -1))));
}
if (nHoriOrient != 0 && xPropertySet.is())